package cn.yunhe.controller;

import cn.yunhe.entity.Log;
import cn.yunhe.service.impl.LogServiceImpl;
import com.github.pagehelper.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
public class LogController {

    @Resource
    private LogServiceImpl logService;


    @RequestMapping("addLog")
    public int addLog(Log log) {
        return logService.addLog(log);

    }

    @RequestMapping("delLog")
    public int delLog(Log log) {
        return logService.delLog(log);
    }


    @RequestMapping("/getLogByPage")
    public Map queryLogByPage(int pageSize, int pageNum, Log log) {
        Map map = new HashMap();
        map.put("pageSize", pageSize);
        map.put("pageNum", pageNum);
        map.put("log", log);
        Page page = logService.getAllLogByPage(map);
        map.put("page", page);
        map.put("totalPage", page.getPages());

        return map;

    }

    public LogServiceImpl getLogService() {
        return logService;
    }

    public void setLogService(LogServiceImpl logService) {
        this.logService = logService;
    }
}
